const app = getApp()
Page({
    data: {
        list: [
            {
                info: "我的帖子",
                icon: "reading",
                handle: 'toReading',
            },
            {
                img_src: "/images/profile/jigou.png",
                info: "我的收藏",
                icon: "volunteer",
                handle: 'toVolunteer',
            },
            {
                info: "我的勋章",
                icon: "medal",
                handle: 'toMedal',
            },
            {
                info: "足印程序",
                icon: "like",
                handle: 'toLike',
            },
        ],
        user: {},
        isLogin: false,
    },
    onLoad() {
        this.getMyData()
    },
    getMyData() {
        let user = app.globalData.user
        let isLogin = app.globalData.isLogin
        this.setData({
            user,
            isLogin,
        })
    },
    changePhoto() {
        if(this.data.photo_src==='/images/profile/photo_default.png'){
            swan.chooseImage({
                count: 1,
                success: res => {
                    console.log(res);
                    let _photo_src = res.tempFilePaths[0]
                    this.setData({
                        photo_src: _photo_src
                    })
                }
            });
        }

    },
    // 登陆认证
    login() {
        let isLogin = this.data.isLogin
        if (!isLogin) {
            swan.navigateTo({
                url: "../profile_pages/login/login"
            })
        }

    },
    // 号召活动
    sponsorActivity() {
        if (app.needLogin()) {
            return
        }
        swan.navigateTo({
            url: "../profile_pages/sponsor/sponsor"
        })
    },
    // 我的参与
    myParticipation() {
        if (app.needLogin()) {
            return
        }
        swan.navigateTo({
            url: "../profile_pages/myParticipation/myParticipation"
        })

    },
    // 我的帖子
    toReading() {
        if (app.needLogin()) {
            return
        }
        // console.log('News');
        swan.navigateTo({
            url: "../profile_pages/reading/reading"
        })

    },
    // 我的收藏
    toVolunteer() {
        if (app.needLogin()) {
            return
        }
        // console.log('News');
        swan.navigateTo({
            url: "../profile_pages/volunteer/volunteer"
        })
    },
    // 我的勋章
    toMedal() {
        if (app.needLogin()) {
            return
        }
        // console.log('News');
        swan.navigateTo({
            url: "../profile_pages/medal/medal"
        })

    },
    // 足印程序
    toLike() {
        swan.navigateTo({
            url: "../profile_pages/like/like"
        })

    },
});